package com.wb.config

import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
import org.springframework.context.annotation.Configuration
import org.springframework.stereotype.Component

@Configuration
open class AOPConfig : ApplicationContextAware {

    companion object {

        var applicationContext: ApplicationContext? = null

        fun <T> getBean(clazz: Class<T>): T {

            return applicationContext!!.getBean(clazz)

        }

    }

    override fun setApplicationContext(applicationContext: ApplicationContext) {
        if (AOPConfig.applicationContext == null) {
            AOPConfig.applicationContext = applicationContext
        }
    }

}